﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class LoginApplicant : System.Web.UI.Page
{
    ApplicantMethord AM = new ApplicantMethord();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        lblError.Text = "";
        if (txtUserName.Text.Equals(""))
        {
            lblError.Text = "UserName can not be empty.";
        }
        else if (txtPassword.Text.Equals(""))
        {
            lblError.Text = "Password can not be empty.";
        }
        else
        {
            bool Result = AM.CheckLoginApplicant(txtUserName.Text, txtPassword.Text);
            if (Result)
            {
                Session["User"] = txtUserName.Text;
                try 
	            {
                    string local = Session["PageCurrent"].ToString();
                    Response.Write("<script type='text/javascript'>window.location = '" + local + "';</script>");
	            }
	            catch (Exception ex)
	            {
                    Response.Redirect("Home.aspx");
	            }
            }
            else
            {
                lblError.Text = "UserName or Password Invalid.";
            }
        }
    }
}